//webpack.config.js

const path = require('path');
const webpack = require('webpack')
module.exports = {

    entry: './src/index.js',

    output: {

        path: path.resolve(__dirname, 'dist'),

        filename: '[name].js'

    },
    mode: "development",
    plugins: [

        //提供全局的变量，在模块中使用无需用require，import引入

        new webpack.ProvidePlugin({

            $: "jquery",

            jQuery: 'jquery'

        }),

    ],


    module: {
        rules: [{
                test: /.jpg|png|gif|bmp/,
                use: [{
                    loader: "url-loader",
                    options: { limit: 8192 }
                }]
            },
            {
                test: /\.js$/,

                loader: 'babel-loader',

                exclude: /node_modules/
            },
            {

                test: /\.css$/,

                use: ['style-loader', 'css-loader']

            },
            {

                test: /\.scss$/,

                use: ['style-loader', 'css-loader', 'sass-loader']

            }

        ]
    }
};